package cn.csdj.sism.service.impl;

import cn.csdj.sism.dao.ConsultantMapper;
import cn.csdj.sism.dao.StudentMapper;
import cn.csdj.sism.pojo.Consultant;
import cn.csdj.sism.pojo.Student;
import cn.csdj.sism.service.ConsultantService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConsultantServiceImpl implements ConsultantService {
    @Autowired
    private ConsultantMapper consultantMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public int insert(Consultant consultant) {
        //获得当前时间
        //--咨询师咨询完成点击确认按钮 -----> 学员信息生成，此时学员状态为 0 (未报名)
        return consultantMapper.insert(consultant);//添加咨询信息;
    }

    @Override
    public int deleteById(Integer id) {
        return consultantMapper.deleteById(id);
    }

    @Override
    public List<Consultant> selectAll() {
        return consultantMapper.selectList(null);
    }

    @Override
    public Consultant selectById(Integer id) {
        return consultantMapper.selectById(id);
    }

    @Override
    public int update(Consultant consultant) {
        return consultantMapper.updateById(consultant);
    }

    /**
     * 分页查询
     *
     * @param current 当前页码
     * @return
     */
    @Override
    public IPage<Consultant> selectPages(Integer current, Integer pageSize) {
//        Page(当前页码，页面大小);
        IPage<Consultant> page = new Page(current,pageSize);
        consultantMapper.selectPage(page,null);
        return page;//返回数据

    }

}
